//获取应用实例
var app = getApp()
var joinRoomUrl = "http://localhost:8888/room/join";
var user = {};
Page({
  data: {
    user : {}
  },
  formBindsubmit:function(e){
      var roomid = e.detail.value.roomId;
         var logUser = app.getLoginUser();
         console.log(JSON.stringify(logUser));
      var uid = app.getLoginUser().uid;
      if(roomid.length!=0){
          wx.request({
            url: joinRoomUrl,
            data: {roomNo:roomid,uid:uid},
            method: 'GET', 
            success: function(res){

             console.log("加入房间返回："+JSON.stringify(res));
                if(res.errMsg=="request:ok"&&res.data.code=="200"){
                  app.setRoomNo(roomid);
                  app.getLoginUser()["rid"]=roomid;
                  wx.navigateTo({
                    url: '/pages/index/index',
                    success: function(res){
                      // success
                    },
                    fail: function() {
                      // fail
                    },
                    complete: function() {
                      // complete
                    }
                  });
                }

            },
            fail: function() {
              // fail
            },
            complete: function() {
              // complete
            }
          })
      }
  },
  create:function(e){
   
  },
  onLoad: function () {
  	app.getUserInfo(function(userInfo){});
  }
})